import React, { useEffect, useState } from "react";
import { Button, Space, Table, Tag } from "antd";
import axios from "axios";
import userr from '../../hooks/user';

function Index() {
  const [data, setData] = useState([]);
  const {isLogin}=userr()
  console.log('isLogin',isLogin);
  
  const getData = () => {
    axios.get("/api/article/list").then((res) => {
      console.log(res);
      setData(res.data.rows);
    });
  };

  useEffect(() => {
    getData();
  }, []);

  const columns = [
    {
      title: "ID",
      dataIndex: "id",
      key: "id",
      render: (text) => <a>{text}</a>,
    },
    {
      title: "详情",
      dataIndex: "content",
      key: "content",
    },
    {
      title: "情况",
      dataIndex: "title",
      key: "title",
    },
    {
      title: "时间",
      dataIndex: "createdAt",
      key: "createdAt",
    },

    {
      title: "Action",
      key: "action",
      render: (_, record) => (
        <Space size="middle">
          <Button style={{ background: "red" }}>删除</Button>
          <Button>在线编辑</Button>
        </Space>
      ),
    },
  ];
  return (
    <div>
      <Table
        columns={columns}
        dataSource={data}
        pagination={{
          total: data,
          showSizeChanger: true,
          showQuickJumper: true,
          showTotal: (total) => `Total ${total} items`,
        }}
      />
    </div>
  );
}

export default Index;
